// Problem 049:
// The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another.
// There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhibiting this property, but there is one other 4-digit increasing sequence.
// What 12-digit number do you form by concatenating the three terms in this sequence?

package main

import (
	"fmt"
	"projecteuler/euler"
)

func p049() {
	euler.FillPrime(10010)
	for i, v := range euler.PrimeList {
		if v <= 1487 {
			continue
		}
		if v > 10000 {
			break
		}
		for j := i + 1; euler.PrimeList[j] < 10000; j++ {
			if w := euler.PrimeList[j]; euler.CompareInDigits(v, w) {
				if euler.IsPrime(2*w-v) && euler.CompareInDigits(v, 2*w-v) {
					fmt.Println("Problem 049:", v*100000000+w*10000+2*w-v)
					return
				}
			}
		}
	}
}
